capture program drop get_wtp_housing

program define get_wtp_housing, rclass

	args arg1

	preserve

	use "$data/raw/HousingCostDistrib/dist_hou_cost.dta", clear
	
	quietly replace min = min(`arg1'/12,min)
	quietly replace max = min(`arg1'/12,max)
	
	local n = _N
	

	forvalues i = 1/`n' {
	
		local sh_hou_cost = sh_hou_cost[`i']
		local max = max[`i']
		local min = min[`i']
		local avg = (`max'+`min')/2
	
		local wtp = `wtp' + `sh_hou_cost'*(`max'+`min')/2
	}
	
	restore
	
	local wtp_year = 12 * `wtp'
	
	return scalar wtp = `wtp_year'
	
end
